export const columns = [
  { label: '', prop: 'index', width: '80px', type: 'index' },
  { label: '业主姓名', prop: 'ownerName', width: '120px', search: true },
  { label: '联系电话', prop: 'phone', width: '150px' },
  { label: '车牌号', prop: 'licensePlate', width: '150px' },
  { label: '临停车位', prop: 'spaceNum', width: '150px' },
  { label: '预约日期', prop: 'reserveDate', type: 'datetime', width: '180px' },
  { label: '开始时间', prop: 'startTime', type: 'datetime', width: '180px' },
  { label: '结束时间', prop: 'endTime', type: 'datetime', width: '180px' },
  {
    label: '状态',
    prop: 'status',
    width: '100px',
    type: 'select',
    options: [
      { label: '待使用', value: 0 },
      { label: '已完成', value: 1 },
      { label: '已取消', value: 2 },
    ],
    search: true,
  },
  {
    label: '核销时间',
    prop: 'verifyTime',
    width: '200px',
    type: 'datetime',
  },
  { label: '备注', prop: 'remark', width: '180px' },
  { label: '操作', prop: 'action', slotName: 'action', width: '120px', fixed: 'right' },
]

export const formOptions = [
  {
    label: '核销临停券',
    prop: 'prizeId',
    type: 'select',
    linkage: 'ownerId',
    options: async (val) => {
      try {
        // /api-parking/parking/prize/drawPrize
        const params = {
          pageNum: 1,
          pageSize: 1000,
          ownerId: val.ownerId, // 1-未使用
          communityId: val.communityId, // 小区ID
        }
        if (!val.ownerId) return []
        const res = await $request.post('/api-parking/parking/prize/queryPrizeByOwnerId', { params })
        console.log('res', res)

        return (res.rows || []).map((item) => ({
          label: `${item.rewardName}-${item.couponCode}`,
          value: item.id,
        }))
      } catch (error) {
        return []
      }
    },
    rules: [{ required: true, message: '核销临停券不能为空' }],
  },
  { label: '核销备注', prop: 'remark', span: 3 },
]
